package com.ss.android.article.base.feature.update.activity;

import android.app.Activity;
import android.content.Context;
import android.graphics.ColorFilter;
import android.os.Bundle;
import android.os.Message;
import android.support.v4.content.ContextCompat;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ImageView;
import android.widget.TextView;

import com.bytedance.article.common.c.TTUtils;
import com.bytedance.common.utility.UIUtils;
import com.bytedance.common.utility.collection.WeakHandler;
import com.bytedance.common.utility.collection.WeakHandler.Callback;
import com.bytedance.frameworks.baselib.network.http.util.TaskInfo;
import com.ss.android.account.Spipe;
import com.ss.android.account.model.BaseUser;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.feature.app.a.ArticleConstants;
import com.ss.android.article.base.feature.feed.vh.CardViewPools;
import com.ss.android.article.base.feature.update.a.UserInfo;
import com.ss.android.article.base.feature.update.a.e;
import com.ss.android.article.base.feature.update.b.UpdateItemMgr;
import com.ss.android.article.base.ui.DiggLayout;
import com.ss.android.article.base.ui.PriorityLinearLayout;
import com.ss.android.article.base.ui.DiggAnimationView;
import com.ss.android.article.browser.R;
import com.ss.android.common.AbsApiThread;
import com.ss.android.common.lib.MobClickCombiner;
import com.ss.android.common.callback.CallbackCenter;
import com.ss.android.common.app.AbsFragment;
import com.ss.android.common.app.LifeCycleMonitor;
import com.ss.android.common.load.AsyncLoader;
import com.ss.android.common.ui.view.PinnedHeaderListView;
import com.ss.android.common.ui.view.SectionListAdapter;
import com.ss.android.common.util.NetworkUtils;
import com.ss.android.common.util.UrlBuilder;
import com.ss.android.image.AsyncImageView;
import com.ss.android.image.BaseImageManager;
import com.ss.android.image.loader.ImageLoader;
import com.ss.android.newmedia.BaseAppData;
import com.ss.android.newmedia.a.TimeFormatter;
import com.ss.android.newmedia.a.AbstractFooter;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

public final class g extends AbsFragment implements Callback,
        com.ss.android.account.b.a.b.b$a,
        com.ss.android.article.base.feature.update.activity.a.a$a,
        com.ss.android.article.base.feature.update.activity.a.b,
        com.ss.android.article.base.feature.update.activity.t.a {
    final class g$a extends AbstractFooter {
        private final g k;
        private View j;

        public g$a(g arg1, View arg2) {
            super(arg2);
            this.k = arg1;
            this.j = arg2;
            this.c();
        }

        public final void onUserClick() {
            this.k.a(false);
        }

        public final void c() {
            UIUtils.setBackgroundResource(this.j, R.drawable.gc);
            int v0 = this.k.a.getResources().getColor(com.ss.android.article.browser.R.color.ww);
            if (this.mFooterTopDivider != null) {
                this.mFooterTopDivider.setBackgroundColor(v0);
            }

            if (this.mFooterBottomDivider != null) {
                this.mFooterBottomDivider.setBackgroundColor(v0);
                this.mFooterBottomDivider.setVisibility(View.GONE);
            }
        }
    }

    final class g$b {
        public long a;
        public int b;
        public int c;
        public boolean d;
        public int e;
        public boolean f;
        public List g;
        public List h;

        public g$b(long arg2, int arg4, boolean arg5) {

            this.a = arg2;
            this.c = arg4;
            this.b = 20;
            this.d = arg5;
            this.h = new ArrayList();
            this.g = new ArrayList();
        }
    }

    static final class c {
        PriorityLinearLayout a;
        TextView b;
        TextView c;
        ImageView d;
        View e;
        AsyncImageView f;
        ImageView g;
        ImageView h;
        TextView i;
        TextView j;
        TextView k;
        View l;
        View m;
        DiggLayout n;
        ImageView o;

        private c() {

        }

        c(byte arg1) {
            this();
        }
    }

    static final class g$d extends SectionListAdapter implements AbsListView.RecyclerListener, LifeCycleMonitor {
        protected final g e;
        List a;
        List b;
        int c;
        Activity d;
        private TimeFormatter g;
        private int h;
        private CardViewPools i;

        public g$d(g arg3, Activity arg4, com.ss.android.article.base.feature.update.a.d arg5) {
            super(((Context) arg4));
            this.e = arg3;
            this.c = 1;
            this.d = arg4;
            this.a = arg5 == null ? new ArrayList() : new ArrayList(arg5.p.f);
            this.g = new TimeFormatter(((Context) arg4));
            this.h = this.d.getResources().getDimensionPixelSize(R.dimen.update_avatar_size);
            this.i = new CardViewPools();
        }

        static Context a(g$d arg1) {
            return arg1.f;
        }

        public final View a(int arg16, View arg17, ViewGroup arg18) {
            View v2;
            g.c v11;
            View v10;
            if (arg17 == null) {
                v10 = LayoutInflater.from(arg18.getContext()).inflate(com.ss.android.article.browser.R.layout.update_comment_item, arg18, false);
                c v3 = new c((byte) 0);
                v3.l = v10.findViewById(com.ss.android.article.browser.R.id.container);
                v3.h = v10.findViewById(com.ss.android.article.browser.R.id.indicator);
                v3.f = v10.findViewById(com.ss.android.article.browser.R.id.avatar);
                v3.e = v10.findViewById(com.ss.android.article.browser.R.id.avatar_layout);
                v3.g = v10.findViewById(com.ss.android.article.browser.R.id.mark_v);
                v3.b = v10.findViewById(com.ss.android.article.browser.R.id.name);
                v3.c = v10.findViewById(com.ss.android.article.browser.R.id.verified_text);
                v3.d = v10.findViewById(com.ss.android.article.browser.R.id.verified_img);
                v3.i = v10.findViewById(com.ss.android.article.browser.R.id.time);
                v3.j = v10.findViewById(com.ss.android.article.browser.R.id.comment);
                v3.m = v10.findViewById(com.ss.android.article.browser.R.id.margin_stub);
                v3.n = v10.findViewById(com.ss.android.article.browser.R.id.digg_layout);
                v3.a = v10.findViewById(com.ss.android.article.browser.R.id.name_layout);
                v3.k = v10.findViewById(com.ss.android.article.browser.R.id.reply_or_delete);
                v3.o = v10.findViewById(com.ss.android.article.browser.R.id.reply_icon);
                v10.setTag(v3);
                v11 = v3;
            } else {
                v11 = (com.ss.android.article.base.feature.update.activity.g.c) arg17.getTag();
                v10 = arg17;
            }

            if (v11 == null) {
                v2 = v10;
            } else {
                v11.m.setVisibility(View.GONE);
                if (arg16 == 0) {
                    v11.h.setVisibility(View.GONE);
                    v11.h.setImageResource(com.ss.android.article.browser.R.drawable.d3);
                } else {
                    v11.h.setVisibility(View.GONE);
                }

                Object v9 = this.a.get(arg16);
                String v2_1 = "";
                if (v9 != null && ((com.ss.android.article.base.feature.update.a.c) v9).d != null) {
                    v2_1 = ((com.ss.android.article.base.feature.update.a.c) v9).d.avatarUrl;
                }

                v11.f.setUrl(v2_1);
                int v2_2 = this.e.h != 3 || v9 == null || ((com.ss.android.article.base.feature.update.a.c) v9).d == null || ((com.ss.android.article.base.feature.update.a.c) v9).d.role != 1 ? 0 : 1;
                ImageView v4 = v11.g;
                int v3_1 = v2_2 != 0 ? 0 : 8;
                UIUtils.setVisibility(((View) v4), v3_1);
                if (v2_2 != 0) {
                    UIUtils.setLayoutParams(v11.g, this.h, -3);
                    UIUtils.setLayoutMargins(v11.g, -3, -3, 0, ((int) UIUtils.dp2px(this.f, -5.5f)));
                    v11.g.setImageResource(com.ss.android.article.browser.R.drawable.uo);
                }

                AsyncImageView v3_2 = v11.f;
                ColorFilter v2_3 = this.e.u ? TTUtils.getNightModeColorFilter() : null;
                v3_2.setColorFilter(v2_3);
                v11.f.setBackgroundResource(com.ss.android.article.browser.R.drawable.update_user_head_bg);
                v11.e.setOnClickListener(new m(this, ((com.ss.android.article.base.feature.update.a.c) v9)));
                if (v9 == null || ((com.ss.android.article.base.feature.update.a.c) v9).d == null) {
                    v11.b.setText("");
                } else {
                    v11.b.setText(((com.ss.android.article.base.feature.update.a.c) v9).d.screenName);
                    if (!((com.ss.android.article.base.feature.update.a.c) v9).d.userVerified || (TextUtils.isEmpty(((com.ss.android.article.base.feature.update.a.c) v9).d.verifiedReason))) {
                        v11.c.setVisibility(View.GONE);
                        v11.d.setVisibility(View.GONE);
                    } else {
                        v11.c.setVisibility(View.VISIBLE);
                        v11.d.setVisibility(View.VISIBLE);
                        v11.c.setText(((com.ss.android.article.base.feature.update.a.c) v9).d.verifiedReason);
                        v11.c.post(new n(v11));
                    }

                    v11.d.setImageResource(com.ss.android.article.browser.R.drawable.all_newv);
                    v11.c.setTextColor(ContextCompat.getColorStateList(this.f, R.color.ssxinzi3));
                    v11.c.setCompoundDrawablesWithIntrinsicBounds(com.ss.android.article.browser.R.drawable.verified_separate_shape, 0, 0, 0);
                    v11.b.setBackgroundResource(com.ss.android.article.browser.R.drawable.by);
                    v11.b.setOnClickListener(new o(this, ((com.ss.android.article.base.feature.update.a.c) v9)));
                    android.support.design.a.a(this.f, this.e.p, ((com.ss.android.article.base.feature.update.a.c) v9).d.authorBadge, ((int) UIUtils.dp2px(this.f, 13f)), v11.a, this.i, this.f.getResources().getDimensionPixelSize(R.dimen.by));
                }

                v11.l.setBackgroundResource(com.ss.android.article.browser.R.color.update_user_list_item_bg_color);
                v11.n.a(com.ss.android.article.browser.R.drawable.nt, R.drawable.ns, this.e.u);
                v11.n.setTextColor$255f295(com.ss.android.article.browser.R.color.ssxinzi9);
                v11.n.setDrawablePadding(0f);
                v11.n.setTextSize(UIUtils.sp2px(this.f, 14f));
                v11.n.setDiggAnimationView(this.e.o);
                v11.n.adaptNightMode(this.e.u);
                v11.j.setTextColor(this.f.getResources().getColor(com.ss.android.article.browser.R.color.wu));
                v11.j.setTextSize(2, ((float) com.ss.android.article.base.feature.update.activity.g.a(this.e.b.mFontSizePref)));
                TextView v2_4 = v11.j;
                UserInfo v3_3 = ((com.ss.android.article.base.feature.update.a.c) v9).e;
                String v4_1 = ((com.ss.android.article.base.feature.update.a.c) v9).c;
                SpannableStringBuilder v5 = new SpannableStringBuilder();
                if (v3_3 != null && !TextUtils.isEmpty(v3_3.screenName)) {
                    v5.append(this.f.getResources().getString(com.ss.android.article.browser.R.string.update_reply));
                    int v6 = v5.length();
                    v5.append(v3_3.screenName);
                    v5.setSpan(new t(this.f, this.e, v3_3), v6, v5.length(), 33);
                    v5.append(": ");
                }

                v5.append(((CharSequence) v4_1));
                v2_4.setText(((CharSequence) v5));
                v11.j.setMovementMethod(new t.b(this.f.getResources().getColor(com.ss.android.article.browser.R.color.fh), t.class));
                v11.j.setOnLongClickListener(new p(this, ((com.ss.android.article.base.feature.update.a.c) v9)));
                v11.i.setTextColor(this.f.getResources().getColor(com.ss.android.article.browser.R.color.ssxinzi9));
                v11.i.setText(this.g.a(((com.ss.android.article.base.feature.update.a.c) v9).b * 1000));
                if (!this.e.c.isLogin || this.e.c.userId != ((com.ss.android.article.base.feature.update.a.c) v9).d.mUserId) {
                    v11.k.setText(com.ss.android.article.browser.R.string.comment_reply);
                } else {
                    v11.k.setText(com.ss.android.article.browser.R.string.comment_delete);
                }

                v11.o.setImageResource(com.ss.android.article.browser.R.drawable.comment_arrow_icon1);
                com.ss.android.article.base.feature.update.activity.r v2_5 = new com.ss.android.article.base.feature.update.activity.r(this, ((com.ss.android.article.base.feature.update.a.c) v9));
                v11.l.setOnClickListener(((View.OnClickListener) v2_5));
                v11.j.setOnClickListener(((View.OnClickListener) v2_5));
                v11.k.setOnClickListener(((View.OnClickListener) v2_5));
                v11.n.setText(UIUtils.a(((com.ss.android.article.base.feature.update.a.c) v9).g));
                v11.n.setSelected(((com.ss.android.article.base.feature.update.a.c) v9).h);
                v11.n.setOnClickListener(new s(this, ((com.ss.android.article.base.feature.update.a.c) v9), v11));
                v2 = v10;
            }

            return v2;
        }

        public final View a(Context arg4, ViewGroup arg5) {
            return LayoutInflater.from(arg4).inflate(com.ss.android.article.browser.R.layout.j4, arg5, false);
        }

        public final void a(View arg5, Object arg6) {
            View v0 = arg5.findViewById(com.ss.android.article.browser.R.id.aci);
            ((TextView) v0).setTextColor(this.f.getResources().getColor(com.ss.android.article.browser.R.color.ssxinzi1));
            ((TextView) v0).setText(((CharSequence) arg6));
            arg5.setBackgroundResource(com.ss.android.article.browser.R.color.update_user_list_item_bg_color);
            arg5.findViewById(com.ss.android.article.browser.R.id.acj).setBackgroundColor(this.f.getResources().getColor(com.ss.android.article.browser.R.color.ww));
        }

        static Context b(g$d arg1) {
            return arg1.f;
        }

        public final void b() {
            super.b();
            if (this.b != null && this.b.size() > 0) {
                this.a(this.b.size(), this.e.getString(com.ss.android.article.browser.R.string.update_hot_comments));
                this.c = 2;
            }

            if (this.a != null && this.a.size() > 0) {
                int v1 = this.a.size();
                int v0 = this.b == null ? 0 : this.b.size();
                v0 = v1 - v0;
                if (v0 <= 0) {
                    return;
                }

                this.a(v0, this.e.getString(com.ss.android.article.browser.R.string.update_all_comments));
            }
        }

        static Context c(g$d arg1) {
            return arg1.f;
        }

        static Context d(g$d arg1) {
            return arg1.f;
        }

        public final void onDestroy() {
        }

        static Context e(g$d arg1) {
            return arg1.f;
        }

        public final void onResume() {
        }

        static Context f(g$d arg1) {
            return arg1.f;
        }

        public final int f() {
            return 2;
        }

        public final void onPause() {
        }

        static List g(g$d arg1) {
            return arg1.a;
        }

        public final int g() {
            return this.a.size();
        }

        public final long getItemId(int arg3) {
            return ((long) arg3);
        }

        public final void onStop() {
        }

        public final void onMovedToScrapHeap(View arg4) {
            Object v0 = arg4.getTag();
            if ((v0 instanceof c)) {
                android.support.design.a.a(((c) v0).a, this.e.p, this.i);
            }
        }
    }

    private TaskInfo A;
    private boolean B;
    private com.ss.android.article.base.feature.update.a.c C;
    private PinnedHeaderListView D;
    private ImageView E;
    private TextView F;
    private View G;
    private ImageView H;
    private BaseImageManager I;
    private int J;
    private boolean K;
    private boolean L;
    private LayoutInflater M;
    private AsyncLoader N;
    private AsyncLoader.LoaderProxy O;
    private Callback P;
    private com.ss.android.article.base.feature.update.b.d.d$a Q;
    public Activity a;
    public AppData b;
    Spipe c;
    long d;
    public long e;
    boolean f;
    int g;
    int h;
    boolean i;
    public com.ss.android.article.base.feature.update.a.d j;
    UserInfo k;
    e l;
    UpdateItemMgr m;
    ViewGroup n;
    DiggAnimationView o;
    ImageLoader p;
    com.ss.android.article.base.feature.update.b.d q;
    com.ss.android.article.base.feature.update.activity.a r;
    g$d s;
    com.ss.android.article.base.feature.update.activity.g.g$a t;
    boolean u;
    boolean v;
    boolean w;
    int x;
    g$b y;
    private static int[] z = new int[]{16, 14, 18, 20};

    public g() {

        this.v = false;
        this.K = false;
        this.L = false;
        this.x = 0;
        this.O = new com.ss.android.article.base.feature.update.activity.h(this);
        this.P = new i();
        new WeakHandler(this.P);
        this.Q = new com.ss.android.article.base.feature.update.b.d.d$a(this);
    }

    static int a(int arg2) {
        int v0 = arg2 < 0 || arg2 >= z.length ? z[0] : z[arg2];
        return v0;
    }

    static boolean a(Context arg7, g$b arg8) {
        JSONArray v1_4;
        com.ss.android.article.base.feature.update.a.c v5;
        int v4;
        JSONArray v2_1;
        JSONObject v3;
        boolean v0 = false;
        arg8.e = 18;
        try {
            if (!NetworkUtils.isNetworkAvailable(arg7)) {
                arg8.e = 12;
                return v0;
            }

            UrlBuilder v1_1 = new UrlBuilder(ArticleConstants.dongtaiCommentListUrlV3);
            v1_1.addParam("id", arg8.a);
            v1_1.addParam("count", arg8.b);
            v1_1.addParam("offset", arg8.c);
            String v1_2 = NetworkUtils.doGet(204800, v1_1.build());
            if (v1_2 == null) {
                return v0;
            }

            if (v1_2.length() == 0) {
                return v0;
            }

            JSONObject v2 = new JSONObject(v1_2);
            if (!"success".equals(v2.optString("message"))) {
                return v0;
            }

            v3 = v2.optJSONObject("data");
            if (v3 == null) {
                return v0;
            }

            arg8.f = AbsApiThread.getHasMore(v3, false);
            v2_1 = v3.optJSONArray("data");
            if (v2_1 != null) {
                v4 = v2_1.length();
                int v1_3;
                for (v1_3 = 0; v1_3 < v4; ++v1_3) {
                    v5 = com.ss.android.article.base.feature.update.a.c.a(v2_1.optJSONObject(v1_3));
                    if (v5 != null) {
                        arg8.h.add(v5);
                    }
                }
            }

            v1_4 = null;
            if (arg8.c == 0) {
                v2_1 = v3.optJSONArray("hot_comments");
            } else {
                v2_1 = v1_4;
            }
            if (v2_1 != null) {
                v4 = v2_1.length();
                int v1_3;
                for (v1_3 = 0; v1_3 < v4; ++v1_3) {
                    v5 = com.ss.android.article.base.feature.update.a.c.a(v2_1.optJSONObject(v1_3));
                    if (v5 != null) {
                        arg8.g.add(v5);
                    }
                }
            }

            arg8.c = Math.max(v3.optInt("offset"), arg8.c + arg8.b);
            arg8.e = 0;
            return true;
        } catch (Exception v1) {
            label_82:
            arg8.e = TTUtils.getErrorCode(arg7, ((Throwable) v1));
            return v0;
        }
    }

    final String a(com.ss.android.article.base.feature.update.a.c arg4) {
        String v0_1;
        StringBuilder v0 = new StringBuilder();
        if (arg4 == null || arg4.d == null) {
            if (this.j != null && this.j.o != null) {
                v0.append("//@").append(this.j.o.screenName).append(": ");
                v0.append(this.j.k);
            }
            v0_1 = v0.toString();
        } else {
            v0.append("//@").append(arg4.d.screenName).append(": ");
            v0.append(arg4.c);
            if (arg4.e != null) {
                v0_1 = v0.toString();
            } else {
                if (this.j != null && this.j.o != null) {
                    v0.append("//@").append(this.j.o.screenName).append(": ");
                    v0.append(this.j.k);
                }
                v0_1 = v0.toString();
            }
        }

        return v0_1;
    }

    public final void a() {
        if (!this.L) {
            this.r.d = this.e();
            this.L = true;
            this.g();
        } else if (this.r != null) {
            this.c.b(this.r);
        }
    }

    public final void a(int arg2, int arg3, BaseUser arg4) {
        if (this.isViewValid()) {
            this.b(arg4);
        }
    }

    public final void a(BaseUser arg2) {
        if (this.isViewValid()) {
            this.b(arg2);
        }
    }

    public final void a(com.ss.android.article.base.feature.update.a.b arg15) {
        long v12 = 0;
        int v10 = -1;
        int v8 = 0;
        if ((this.isViewValid()) && arg15 != null && arg15.g != null) {
            com.ss.android.article.base.feature.update.a.d v0 = this.j;
            com.ss.android.article.base.feature.update.a.c v1 = arg15.g;
            if (v1 != null) {
                ++v0.c;
                v0.p.f.add(0, v1);
            }

            if (AppData.getInstance().bo.get(Long.valueOf(this.j.i)) != null) {
                AppData.getInstance().a(this.j.i, this.j.a, this.j.b, this.j.c);
            }

            g$d v1_1 = this.s;
            com.ss.android.article.base.feature.update.a.c v2 = arg15.g;
            int v0_1 = v1_1.b != null ? v1_1.b.size() : 0;
            v0_1 = Math.min(v0_1, v1_1.a.size());
            v1_1.a.add(v0_1, v2);
            v1_1.notifyDataSetChanged();
            v0_1 += v1_1.c;
            this.m.b(this.j);
            this.c();
            if (this.e > v12) {
                CallbackCenter.notifyCallback(BaseAppData.callbackTypeCommentExtraInfoChanged, new Object[]{BaseAppData.callbackTypeCommentExtraInfoChanged, Long.valueOf(this.e), Integer.valueOf(this.j.c), Integer.valueOf(v10), Boolean.valueOf(true)});
            }

            if ((arg15.h) && this.a != null) {
                MobClickCombiner.onEvent(this.a, "update_detail", "reply_media_comment", this.e, v12);
            }

            int v1_2 = this.D.getFirstVisiblePosition();
            int v2_1 = this.D.getLastVisiblePosition();
            int v3 = this.D.getHeaderViewsCount() + v0_1;
            if (v1_2 < v3 && v2_1 > v3) {
                return;
            }

            v0_1 = v1_2 >= v3 ? 1 : 0;
            PinnedHeaderListView v1_3 = this.D;
            if (v0_1 != 0) {
                v8 = v10;
            }

            v1_3.smoothScrollToPosition(v3 + v8);
        }
    }

    public final void a(UserInfo arg2, int arg3) {
        if (arg3 == 1) {
            if (this.c.isLogin) {
                this.a("click_digger");
            } else {
                this.a("logoff_click_digger");
            }
        } else if (arg3 == 2) {
            if (this.c.isLogin) {
                this.a("click_replier");
            } else {
                this.a("logoff_click_replier");
            }
        }

        AppData.aK();
    }

    public final void a(String arg3) {
        if (this.a != null) {
            MobClickCombiner.onEvent(this.a, "update_detail", arg3);
        }
    }

    public final void a(boolean arg6) {
        Object v4 = null;
        if (this.y == null) {
            if (!arg6) {
                this.a("more_comment");
            }

            this.y = new g$b(this.d, this.x, arg6);
            this.N.addTask(Long.valueOf(this.d), this.y, v4, v4);
        }
    }

    public final void b() {
        if (!this.w && (this.K) && this.j != null && this.j.i > 0) {
            if (this.M != null && this.m != null && this.D != null && this.j != null) {
                boolean v0 = this.j.c > 0 ? true : false;
                this.v = v0;
                if (this.t == null) {
                    View v0_1 = this.M.inflate(com.ss.android.article.browser.R.layout.j2, this.D, false);
                    this.D.addFooterView(v0_1, null, false);
                    this.t = new g$a(this, v0_1.findViewById(com.ss.android.article.browser.R.id.ss_footer_content));
                }

                this.t.hideFooterContent();
                this.d();
                this.s = new g$d(this, this.a, this.j);
                this.D.setAdapter(this.s);
                this.D.setRecyclerListener(this.s);
                this.registerLifeCycleMonitor(this.s);
                if (this.B) {
                    this.D.setSelection(this.D.getHeaderViewsCount());
                }

                this.g();
            }

            this.a(true);
            this.w = true;
        }
    }

    private void b(BaseUser arg5) {
        if (arg5 != null && this.k != null && (arg5.mUserId == this.k.mUserId || arg5.mMessageUserId == this.k.mUserId)) {
            this.j.o = ((UserInfo) arg5);
            this.k = this.j.o;
            this.q.a(this.f());
        }
    }

    public final void b(int arg3) {
        android.support.design.a.showImageToast(this.getContext(), arg3, R.drawable.close_popup_textpage);
    }

    public final void c() {
        if ((this.isViewValid()) && this.m != null && this.q != null && (this.K)) {
            com.ss.android.article.base.feature.update.a.d v0 = this.m.b(this.d);
            this.l = this.m.a(this.d);
            if (v0 != null && v0.o != null && this.l != null) {
                this.j = v0;
                this.k = v0.o;
                this.q.a(this.l);
                this.q.a(this.f());
            }
        }
    }

    final void d() {
        if (this.v) {
            this.t.switchToLoading();
        } else {
            this.t.hideFooterContent();
        }
    }

    final com.ss.android.article.base.feature.update.a.b e() {
        com.ss.android.article.base.feature.update.a.b v1;
        UserInfo v4 = null;
        if ((this.L) || this.C == null) {
            v1 = new com.ss.android.article.base.feature.update.a.b(this.d, v4, ((com.ss.android.article.base.feature.update.a.c) null), "");
            this.a(((com.ss.android.article.base.feature.update.a.c) null));
        } else {
            v1 = new com.ss.android.article.base.feature.update.a.b(this.d, this.C.d, this.C, "");
            this.a(this.C);
        }

        v1.h = this.f;
        return v1;
    }

    final boolean f() {
        boolean v0;
        if (this.c.isLogin) {
            if ((this.c.isLogin) && this.k != null && this.k.mUserId != this.c.userId) {
                return true;
            }

            v0 = false;
        } else {
            label_13:
            v0 = true;
        }

        return v0;
    }

    private void g() {
        String v0 = (this.L) || this.C == null || this.C.d == null ? this.b.getWriteCommentHint() : this.getString(com.ss.android.article.browser.R.string.reply_comment) + this.C.d.screenName + ":";
        this.F.setText(((CharSequence) v0));
    }

    public final void handleMsg(Message message) {
        if (message != null) {
            if (message.what != 1005) {
            } else if ((message.obj instanceof com.ss.android.article.base.feature.update.a.d)) {
                Object v0 = message.obj;
                if (v0 != null) {
                    this.j.a(((com.ss.android.article.base.feature.update.a.d) v0));
                    com.ss.android.article.base.feature.update.b.d v0_1 = this.q;
                    com.ss.android.article.base.feature.update.a.d v1 = this.j;
                    if (v1 != null) {
                        v0_1.u.a(v1);
                    }
                }
            }
        }
    }

    public final void onActivityCreated(Bundle arg11) {
        boolean v8 = true;
        super.onActivityCreated(arg11);
        this.K = true;
        if (this.M != null && this.m != null) {
            this.G = this.M.inflate(com.ss.android.article.browser.R.layout.j7, this.D, false);
            View v0 = this.G.findViewById(com.ss.android.article.browser.R.id.acx);
            ((DiggLayout) v0).a(com.ss.android.article.browser.R.drawable.nt, R.drawable.ns, this.u);
            ((DiggLayout) v0).setTextColor$255f295(com.ss.android.article.browser.R.color.ssxinzi9);
            ((DiggLayout) v0).setTextSize(UIUtils.sp2px(this.getActivity(), 14f));
            ((DiggLayout) v0).setDrawablePadding(0f);
            ((DiggLayout) v0).setDiggAnimationView(this.o);
            if (this.h != 3) {
                v8 = false;
            }

            this.q = new com.ss.android.article.base.feature.update.b.d(this.a, this.G, this.Q, this.o, this.g, "update_detail", new AtomicBoolean(false), v8, this.E);
            this.q.A = this.p;
            this.l = this.m.f;
            this.D.addHeaderView(this.G);
            if (((this.getActivity() instanceof UpdateDetailActivity)) && (((UpdateDetailActivity) this.getActivity()).b)) {
                this.l = null;
            }

            if (this.l != null && this.l.a != null) {
                this.j = (com.ss.android.article.base.feature.update.a.d) this.l.a;
                this.q.a(this.l);
            }

            this.q.q.setOnClickListener(new com.ss.android.article.base.feature.update.activity.j(this));
        }

        if (this.F != null) {
            this.F.setOnClickListener(new k(this));
        }

        if (this.D != null) {
            this.D.setOnScrollListener(new com.ss.android.article.base.feature.update.activity.l(this));
        }

        this.b();
    }

    public final void onCreate(Bundle bundle) {
        JSONObject v0_1;
        int v10 = 4;
        long v6 = 0;
        super.onCreate(bundle);
        this.a = this.getActivity();
        this.b = AppData.getInstance();
        this.c = Spipe.inst();
        this.M = LayoutInflater.from(this.a);
        com.ss.android.account.b.a.b.a(this.a);
        Bundle v2 = this.getArguments();
        this.d = v2.getLong("id", v6);
        this.e = v2.getLong("comment_id", v6);
        this.f = v2.getBoolean("replay_zz_comment");
        long v4 = v2.getLong("update_comment_id", v6);
        String v3 = v2.getString("update_user_str");
        if (v4 > v6 && !android.support.design.a.isTextEmpty(v3)) {
            JSONObject v1 = null;
            try {
                v0_1 = new JSONObject(v3);
            } catch (JSONException v0) {
                v0_1 = v1;
            }

            UserInfo v0_2 = UserInfo.fromJO(v0_1, true);
            if (v0_2 == null) {
            } else {
                this.C = new com.ss.android.article.base.feature.update.a.c(v4);
                this.C.d = v0_2;
            }
        }

        if (this.d > v6 || this.e > v6) {
            this.setUserVisibleHint(true);
        }

        this.B = v2.getBoolean("view_comments", false);
        this.i = v2.getBoolean("show_comment_dialog", false);
        this.g = v2.getInt("item_type", -1);
        this.h = v2.getInt("update_item_source", v10);
        v2.getString("explict_desc");
        v2.getLong("ad_id", v6);
        this.A = new TaskInfo();
        this.m = UpdateItemMgr.getInstance(this.a);
        this.N = new AsyncLoader(v10, 1, this.O);
        this.r = new com.ss.android.article.base.feature.update.activity.a(this.a);
        this.r.k = this;
        this.r.e = this;
        this.I = new BaseImageManager(this.a);
        DisplayMetrics v8 = this.a.getResources().getDisplayMetrics();
        this.p = new ImageLoader(this.a, this.A, 16, 20, 2, this.I, v8.widthPixels, v8.heightPixels);
    }

    public final View onCreateView(LayoutInflater arg3, ViewGroup arg4, Bundle arg5) {
        this.n = (ViewGroup) arg3.inflate(R.layout.j6, arg4, false);
        this.D = this.n.findViewById(com.ss.android.article.browser.R.id.listview);
        this.o = com.ss.android.article.base.ui.DiggAnimationView.a(this.n);
        this.F = this.n.findViewById(com.ss.android.article.browser.R.id.aco);
        this.E = this.n.findViewById(com.ss.android.article.browser.R.id.acn);
        this.H = this.a.findViewById(com.ss.android.article.browser.R.id.yl);
        UIUtils.setVisibility(this.H, 8);
        return this.n;
    }

    public final void onDestroy() {
        if (this.N != null) {
            this.N.stop();
        }

        if (this.A != null) {
            this.A.a = true;
        }

        if (this.p != null) {
            this.p.onDestroy();
        }

        super.onDestroy();
    }

    public final void onResume() {
        super.onResume();
        if (this.N != null) {
            this.N.resume();
        }

        AppData.getInstance();
        boolean v0 = AppData.isNightMode();
        int v1 = AppData.getInstance().mFontSizePref;
        if (this.u != v0 || this.J != v1) {
            this.u = v0;
            this.J = v1;
            this.c();
            if (this.t != null) {
                this.t.c();
            }

            if (this.s != null) {
                this.s.notifyDataSetChanged();
            }

            this.n.setBackgroundResource(com.ss.android.article.browser.R.color.ssxinmian4);
        }

        if ((this.i) && this.r != null && !this.r.isShowing() && this.j != null) {
            this.r.a(this.e());
            this.i = false;
        }

        if (this.p != null) {
            this.p.onPause();
        }
    }

    public final void onStop() {
        if (this.N != null) {
            this.N.pause();
        }

        super.onStop();
        if (this.p != null) {
            this.p.onStop();
        }
    }
}

